import axios from 'axios';

const API_BASE_URL = 'http://localhost:8082/api';

export const userService = {
  // 获取用户列表
  getUsers: async (params) => {
    const response = await axios.get(`${API_BASE_URL}/users`, { params });
    return response.data;
  },

  // 创建新用户
  createUser: async (userData) => {
    const response = await axios.post(`${API_BASE_URL}/users`, userData);
    return response.data;
  },

  // 更新用户信息
  updateUser: async (userId, userData) => {
    const response = await axios.put(`${API_BASE_URL}/users/${userId}`, userData);
    return response.data;
  },

  // 删除用户
  deleteUser: async (userId) => {
    await axios.delete(`${API_BASE_URL}/users/${userId}`);
    return true;
  }
};